// #include <gmock/gmock.h>
#include <gtest/gtest.h>

#include "event_driven/event_driver.h"

class EventDriverTest : public ::testing::Test
{
  protected:
    void SetUp() override
    {
        // 初始化代码 (需要时)
    }
};

void hardwareMonitor(Scheduler& scheduler, const std::atomic<bool>& testRunning)
{
    srand(time(nullptr));
    while (testRunning.load())
    {
        std::this_thread::sleep_for(std::chrono::microseconds(50));
        const auto priority = random() % 3;
        Event ev((EventPriority)priority,
                 [priority]() { printf("priority: %d\n", static_cast<uint8_t>(priority)); });

        scheduler.postEvent(std::move(ev));
    }
};

TEST_F(EventDriverTest, BasicTest)
{
    Scheduler scheduler;
    scheduler.start();

    std::atomic<bool> testRunning{true};
    std::thread thread(&hardwareMonitor, std::ref(scheduler), std::ref(testRunning));

    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    testRunning.store(false);

    thread.join();
    scheduler.stop();
}